package com.ld.control.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

    public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
    public static final String YYYYMMDDHHMMSS2 = "yyyy/MM/dd/ HH:mm:ss";
    public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

    public static Long currentTimeMillis() {
        return System.currentTimeMillis();
    }

    /**
     * 将日期转换成指定日期格式
     *
     * @param date
     * @param pattern
     * @return
     */
    public static String dateToStr(Date date, String pattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        String formatDateStr = dateFormat.format(date);
        return formatDateStr;
    }

    /**
     * 给某个时间加多少秒
     * @param date
     * @param second
     * @return
     */
    public static Date dateAddSecond(Date date, Long second) {
        second = second * 1000;
        date.setTime(date.getTime() + second);
        return date;
    }
}
